﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace LWrap.FileParsers
{
    public class FileParserFactory
    {
        public static FileParserBase GetFileParser(string filePath)
        {
            string fileExt = filePath.Substring(filePath.Length - 3, 3).ToLower();
            FileParserBase parser = null;
            if (fileExt == "htm")
                fileExt = "html";

            switch (fileExt)
            {
                case "pdf":
                    parser=new PDFFileParser();
                    break;
                case "doc":
                    parser=new WordFileParser();
                    break;
                case "txt":
                    parser=new TextFileParser();
                    break;
                case "html":
                    parser = new HTMLFileParser();
                    break;
                case "xml":
                    parser = new XMLFileParser();
                    break;
            }
            return parser;
        }
    }
}
